//
//  GroupUserModel10.m
//
//  Created by lianchuang  on 14-11-25
//  Copyright (c) 2014 __MyCompanyName__. All rights reserved.
//

#import "GroupUserModel.h"


NSString *const kGroupUserModel10Pid = @"pid";
NSString *const kGroupUserModel10Todayposts = @"todayposts";
NSString *const kGroupUserModel10Displayorder = @"displayorder";
NSString *const kGroupUserModel10Members = @"members";
NSString *const kGroupUserModel10Dateline = @"dateline";
NSString *const kGroupUserModel10Lastpost = @"lastpost";
NSString *const kGroupUserModel10Title = @"title";
NSString *const kGroupUserModel10Threads = @"threads";
NSString *const kGroupUserModel10Posts = @"posts";
NSString *const kGroupUserModel10Gid = @"gid";
NSString *const kGroupUserModel10Icon = @"icon";

NSString *const kGroupUserModel10Color =@"color";
NSString *const kGroupUserModel10Description = @"description";
NSString *const kGroupUserModel10Iscollect = @"iscollect";
NSString *const kGroupUserModel10Moderator = @"moderator";
NSString *const kGroupUserModel10Moderators = @"moderators";
NSString *const kGroupUserModel10Lastposttitle = @"lastposttitle";


@interface GroupUserModel ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation GroupUserModel

@synthesize pid = _pid;
@synthesize todayposts = _todayposts;
@synthesize displayorder = _displayorder;
@synthesize members = _members;
@synthesize dateline = _dateline;
@synthesize lastpost = _lastpost;
@synthesize title = _title;
@synthesize threads = _threads;
@synthesize posts = _posts;
@synthesize gid = _gid;
@synthesize icon = _icon;

@synthesize color = _color;
@synthesize description1 = _description1;
@synthesize iscollect = _iscollect;
@synthesize moderator = _moderator;
@synthesize moderators = _moderators;
@synthesize lastposttitle = _lastposttitle;



+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if(self && [dict isKindOfClass:[NSDictionary class]]) {
            self.pid = [self objectOrNilForKey:kGroupUserModel10Pid fromDictionary:dict];
            self.todayposts = [self objectOrNilForKey:kGroupUserModel10Todayposts fromDictionary:dict];
            self.displayorder = [self objectOrNilForKey:kGroupUserModel10Displayorder fromDictionary:dict];
            self.members = [self objectOrNilForKey:kGroupUserModel10Members fromDictionary:dict];
            self.dateline = [self objectOrNilForKey:kGroupUserModel10Dateline fromDictionary:dict];
            self.lastpost = [self objectOrNilForKey:kGroupUserModel10Lastpost fromDictionary:dict];
            self.title = [self objectOrNilForKey:kGroupUserModel10Title fromDictionary:dict];
            self.threads = [self objectOrNilForKey:kGroupUserModel10Threads fromDictionary:dict];
            self.posts = [self objectOrNilForKey:kGroupUserModel10Posts fromDictionary:dict];
            self.gid = [self objectOrNilForKey:kGroupUserModel10Gid fromDictionary:dict];
            self.icon = [self objectOrNilForKey:kGroupUserModel10Icon fromDictionary:dict];
        
        
        self.color = [self objectOrNilForKey:kGroupUserModel10Color fromDictionary:dict];
        self.description1 = [self objectOrNilForKey:kGroupUserModel10Description fromDictionary:dict];
        self.iscollect = [self objectOrNilForKey:kGroupUserModel10Iscollect fromDictionary:dict];
        self.moderator = [self objectOrNilForKey:kGroupUserModel10Moderator fromDictionary:dict];
        self.moderators = [self objectOrNilForKey:kGroupUserModel10Moderators fromDictionary:dict];
        
        
        self.lastposttitle = [self objectOrNilForKey:kGroupUserModel10Lastposttitle fromDictionary:dict];

        
        
        
        
        
        
        


    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.pid forKey:kGroupUserModel10Pid];
    [mutableDict setValue:self.todayposts forKey:kGroupUserModel10Todayposts];
    [mutableDict setValue:self.displayorder forKey:kGroupUserModel10Displayorder];
    [mutableDict setValue:self.members forKey:kGroupUserModel10Members];
    [mutableDict setValue:self.dateline forKey:kGroupUserModel10Dateline];
    [mutableDict setValue:self.lastpost forKey:kGroupUserModel10Lastpost];
    [mutableDict setValue:self.title forKey:kGroupUserModel10Title];
    [mutableDict setValue:self.threads forKey:kGroupUserModel10Threads];
    [mutableDict setValue:self.posts forKey:kGroupUserModel10Posts];
    [mutableDict setValue:self.gid forKey:kGroupUserModel10Gid];
    [mutableDict setValue:self.icon forKey:kGroupUserModel10Icon];
    
    
    [mutableDict setValue:self.icon forKey:kGroupUserModel10Color];
    [mutableDict setValue:self.description1 forKey:kGroupUserModel10Description];
    [mutableDict setValue:self.iscollect forKey:kGroupUserModel10Iscollect];
    [mutableDict setValue:self.moderator forKey:kGroupUserModel10Moderator];
    [mutableDict setValue:self.moderators forKey:kGroupUserModel10Moderators];

    [mutableDict setObject:self.lastposttitle forKey:kGroupUserModel10Lastposttitle];
    
    
    
    
    
    


    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description 
{
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];

    self.pid = [aDecoder decodeObjectForKey:kGroupUserModel10Pid];
    self.todayposts = [aDecoder decodeObjectForKey:kGroupUserModel10Todayposts];
    self.displayorder = [aDecoder decodeObjectForKey:kGroupUserModel10Displayorder];
    self.members = [aDecoder decodeObjectForKey:kGroupUserModel10Members];
    self.dateline = [aDecoder decodeObjectForKey:kGroupUserModel10Dateline];
    self.lastpost = [aDecoder decodeObjectForKey:kGroupUserModel10Lastpost];
    self.title = [aDecoder decodeObjectForKey:kGroupUserModel10Title];
    self.threads = [aDecoder decodeObjectForKey:kGroupUserModel10Threads];
    self.posts = [aDecoder decodeObjectForKey:kGroupUserModel10Posts];
    self.gid = [aDecoder decodeObjectForKey:kGroupUserModel10Gid];
    self.icon = [aDecoder decodeObjectForKey:kGroupUserModel10Icon];
    
    
    
    self.color = [aDecoder decodeObjectForKey:kGroupUserModel10Icon];
    self.description1 = [aDecoder decodeObjectForKey:kGroupUserModel10Description];
    self.iscollect = [aDecoder decodeObjectForKey:kGroupUserModel10Iscollect];
    self.moderator = [aDecoder decodeObjectForKey:kGroupUserModel10Moderator];
    self.moderators = [aDecoder decodeObjectForKey:kGroupUserModel10Moderators];
    self.lastposttitle = [aDecoder decodeObjectForKey:kGroupUserModel10Lastposttitle];
    
    

    
    
    
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_pid forKey:kGroupUserModel10Pid];
    [aCoder encodeObject:_todayposts forKey:kGroupUserModel10Todayposts];
    [aCoder encodeObject:_displayorder forKey:kGroupUserModel10Displayorder];
    [aCoder encodeObject:_members forKey:kGroupUserModel10Members];
    [aCoder encodeObject:_dateline forKey:kGroupUserModel10Dateline];
    [aCoder encodeObject:_lastpost forKey:kGroupUserModel10Lastpost];
    [aCoder encodeObject:_title forKey:kGroupUserModel10Title];
    [aCoder encodeObject:_threads forKey:kGroupUserModel10Threads];
    [aCoder encodeObject:_posts forKey:kGroupUserModel10Posts];
    [aCoder encodeObject:_gid forKey:kGroupUserModel10Gid];
    [aCoder encodeObject:_icon forKey:kGroupUserModel10Icon];
    
    
    
    [aCoder encodeObject:_icon forKey:kGroupUserModel10Color];
    [aCoder encodeObject:_description1 forKey:kGroupUserModel10Description];
    [aCoder encodeObject:_iscollect forKey:kGroupUserModel10Iscollect];
    [aCoder encodeObject:_moderator forKey:kGroupUserModel10Moderator];
    [aCoder encodeObject:_moderators forKey:kGroupUserModel10Moderators];

    [aCoder encodeObject:_lastposttitle forKey:kGroupUserModel10Lastposttitle];
    

}

- (id)copyWithZone:(NSZone *)zone
{
    GroupUserModel *copy = [[GroupUserModel alloc] init];
    
    if (copy) {

        copy.pid = [self.pid copyWithZone:zone];
        copy.todayposts = [self.todayposts copyWithZone:zone];
        copy.displayorder = [self.displayorder copyWithZone:zone];
        copy.members = [self.members copyWithZone:zone];
        copy.dateline = [self.dateline copyWithZone:zone];
        copy.lastpost = [self.lastpost copyWithZone:zone];
        copy.title = [self.title copyWithZone:zone];
        copy.threads = [self.threads copyWithZone:zone];
        copy.posts = [self.posts copyWithZone:zone];
        copy.gid = [self.gid copyWithZone:zone];
        copy.icon = [self.icon copyWithZone:zone];
        
        
        
        copy.color = [self.copy copyWithZone:zone];
        copy.description1 = [self.description1 copyWithZone:zone];
        copy.iscollect = [self.iscollect copyWithZone:zone];
        copy.moderator = [self.moderator copyWithZone:zone];
        copy.moderators = [self.moderators copyWithZone:zone];
        copy.lastposttitle = [self.lastposttitle copyWithZone:zone];
        
       }
    
    return copy;
}


@end
